# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        博智科技  
# Name:         demo1323
# Description:
# Author:       yzl
# Date:         2019-02-08
#-------------------------------------------------------------------------------

import os

f = open('url.txt','a+')
url = ''
# 充值指针到开始
f.seek(0)
while True:
    # 读一行数据
    url = f.readline()
    # print(url)
    # 去掉换行符
    url = url.rstrip()
    if url == '':
        break
    else:
        print(url)

f.seek(0)
# print(f.readlines()) # 指针到了最后一行 \r\n
# 写入单行数据
f.write('https://www.baidu.com' + os.linesep)
f.close()

f = open('url.txt','a+')
urllist = [
    'https://www.google.com' + os.linesep ,
    'https://www.sina.com.cn' + os.linesep
]
# 写入多行数据
f.writelines(urllist)
f.close()